package com.twu.biblioteca.actions;

import com.twu.biblioteca.controllers.BookController;
import com.twu.biblioteca.controllers.UserController;

import java.util.Scanner;

public class SelectBook implements Action {
    private UserController userController;
    private BookController bookController;
    private Scanner scanner;

    public SelectBook(UserController userController, BookController bookController, Scanner scanner) {
        this.userController = userController;
        this.bookController = bookController;
        this.scanner = scanner;
    }

    @Override
    public String displayName() {
        return "Reserve book";
    }

    @Override
    public void perform() {
        if (userController.getCurrentUser() == null) {
            System.out.println("Only authenticated users can make a reserve.");
            return;
        }

        System.out.print("Input the book id: ");

        int id = scanner.nextInt();

        System.out.println();
        System.out.println(bookController.reserveBook(id));
    }
}
